package hoang.android.app.youtube;

import hoang.android.app.R;
import android.os.Bundle;
import android.widget.Button;

import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayer.Provider;
import com.google.android.youtube.player.YouTubePlayerView;

public class DetailVideo extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener{

	public static final String DEVELOPER_KEY = "AIzaSyDjqVLvsaSq51K9tXMDTJ3aQ_ZVsjGWT8M";
	
	YouTubePlayerView youtubePlayerView;
	Button _btPlayList;
	private String _videoId = null;
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_detail_video);
		
		
		youtubePlayerView = (YouTubePlayerView)findViewById(R.id.youtubeView);
		youtubePlayerView.initialize(DEVELOPER_KEY, this);
		
		Bundle mBundle = getIntent().getExtras();
		if(mBundle!=null){
			_videoId = mBundle.getString(ListVideo.KEY);
		}
		
	}

	@Override
	public void onInitializationFailure(Provider arg0,
			YouTubeInitializationResult arg1) {
		
	}

	@Override
	public void onInitializationSuccess(Provider provider, YouTubePlayer youtubePlayer,
			boolean wasRestored) {
		
		if(!wasRestored && _videoId!=null){
			youtubePlayer.cueVideo(_videoId);
		}
	}
}
